<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <SCript>
    let arr = [8, 9, 5, 4]
    function fn(x=[]) {
      let max = x[0]
      let min = x[0]
      for (let i = 0; i < x.length; i++) {
        if (max < x[i]) {
          max = x[i]
        }
        if (min > x[i]) {
          min = x[i]
        }
      }
      return [max, min]
    }
    let re = fn(arr)
    console.log(re)
  </SCript>
</body>

</html>